<template>
    <div id="huizong-detail">
        <el-dialog
            :title="titleCon"
            v-model="isUseDialog" 
            draggable 
            :close-on-click-modal="false" 
            width="60%" 
            :before-close="handleClose"
            :destroy-on-close="true"
        >
            <el-divider content-position="left">{{ $t('poG0ViSaxZGwiMhRkA8uT') }}</el-divider>
            <el-form :model="ruleForm" size="default">
                <el-row :gutter="35">
                    <el-col :xs="24" :sm="12" :md="12" :lg="12" :xl="12" class="mb20">
                        <el-form-item :label-width="formLabelWidth" :label="$t('kJu7Trhi2W73OAVloSf')">
                            <el-input readonly v-model="ruleForm.v_ProjectName" :placeholder="$t('kJu7Trhi2W73OAVloSf')" clearable />
                        </el-form-item>
                    </el-col>
                    <el-col :xs="24" :sm="12" :md="12" :lg="12" :xl="12" class="mb20">
                        <el-form-item :label-width="formLabelWidth" :label="$t('znlr2HhiXheU4cdB8JdS4')">
                            <el-input readonly v-model="ruleForm.v_ApplyContent" :placeholder="$t('znlr2HhiXheU4cdB8JdS4')" clearable />
                        </el-form-item>
                    </el-col>
                    <el-col :xs="24" :sm="12" :md="12" :lg="12" :xl="12" class="mb20">
                        <el-form-item :label-width="formLabelWidth" :label="$t('0EDVq0EaoQowa5yp4H0')">
                            <template v-if="ruleForm.d_JobDate === '1900-01-01 00:00:00'">
                                <div style="color:#c0c4cc;" class="path_look">
                                    <span> - </span>
                                </div>
                            </template>
                            <el-input v-else readonly v-model="ruleForm.d_JobDate" :placeholder="$t('0EDVq0EaoQowa5yp4H0')" clearable />
                        </el-form-item>
                    </el-col>
                    <el-col :xs="24" :sm="12" :md="12" :lg="12" :xl="12" class="mb20">
                        <el-form-item :label-width="formLabelWidth" :label="$t('xuuQbgKgXbSnhNsF78bC')">
                            <el-input readonly v-model="ruleForm.v_JobAddress" :placeholder="$t('xuuQbgKgXbSnhNsF78bC')" clearable />
                        </el-form-item>
                    </el-col>
                    <el-col :xs="24" :sm="12" :md="12" :lg="12" :xl="12" class="mb20">
                        <el-form-item :label-width="formLabelWidth" :label="$t('9k1l8ZfhXdrs9DDwIHlt')">
                            <el-input readonly v-model="ruleForm.n_Type" :placeholder="$t('9k1l8ZfhXdrs9DDwIHlt')" clearable />
                        </el-form-item>
                    </el-col>
                    <el-col :xs="24" :sm="12" :md="12" :lg="12" :xl="12" class="mb20">
                        <el-form-item :label-width="formLabelWidth" :label="$t('jfvBMMqrg8Hgmvf1QvEr')">
                            <el-input readonly v-model="ruleForm.d_AuditTime" :placeholder="$t('jfvBMMqrg8Hgmvf1QvEr')" clearable />
                        </el-form-item>
                    </el-col>
                    <el-col :xs="24" :sm="12" :md="12" :lg="12" :xl="12" class="mb20">
                        <el-form-item :label-width="formLabelWidth" :label="$t('a_4BebW8b0g3aixOGa4Hj')">
                            <el-input readonly v-model="ruleForm.v_TeamName" :placeholder="$t('a_4BebW8b0g3aixOGa4Hj')" clearable />
                        </el-form-item>
                    </el-col>
                    <el-col :xs="24" :sm="12" :md="12" :lg="12" :xl="12" class="mb20">
                        <el-form-item :label-width="formLabelWidth" :label="$t('tPiWuSFanLeOKbJWvfz')">
                            <el-input readonly v-model="ruleForm.v_ApplyEmpName" :placeholder="$t('tPiWuSFanLeOKbJWvfz')" clearable />
                        </el-form-item>
                    </el-col>
                    <el-col :xs="24" :sm="12" :md="12" :lg="12" :xl="12" class="mb20">
                        <el-form-item :label-width="formLabelWidth" :label="$t('sXyZ6PqmWwEIov0bNsb')">
                            <el-input readonly v-model="ruleForm.v_AuditEmpName" :placeholder="$t('sXyZ6PqmWwEIov0bNsb')" clearable />
                        </el-form-item>
                    </el-col>
                    <el-col :xs="24" :sm="12" :md="12" :lg="12" :xl="12" class="mb20">
                        <el-form-item :label-width="formLabelWidth" :label="$t('z_6MaI6MYIAjEp9UeAfF')">
                            <el-input v-if="ruleForm.v_CheckChangeEmpName" readonly v-model="ruleForm.v_CheckChangeEmpName" :placeholder="$t('z_6MaI6MYIAjEp9UeAfF')" clearable />
                            <el-input v-else readonly v-model="defaultVal" :placeholder="$t('z_6MaI6MYIAjEp9UeAfF')" clearable />
                        </el-form-item>
                    </el-col>
                    <!-- <el-col :xs="24" :sm="12" :md="12" :lg="12" :xl="12" class="mb20">
                        <el-form-item :label-width="formLabelWidth" :label="$t('s4KbtSrTfOzuWyRcHgTxx')">
                            <template v-if="ruleForm.v_FilePath !== ''">
                                <el-link style="padding-left: 15px;" target="_blank" class="path_look" :href="pathData + ruleForm.v_FilePath" type="primary">{{ $t('ms1fpd4AXyStopkHw95Z8') }}</el-link>
                            </template>
                            <template v-else>
                                <div style="color:#c0c4cc;" class="path_look">
                                    <span>{{ $t('tzv7Fao_8LvfFbddIkvDu') }}</span>
                                </div>
                            </template>
                        </el-form-item>
                    </el-col> -->
                    <el-col :xs="24" :sm="12" :md="12" :lg="12" :xl="12" class="mb20">
                        <el-form-item :label-width="formLabelWidth" :label="$t('rgcgOzqZdO2BeC4ZlZlTu')">
                            <el-switch
                                v-model="ruleForm.n_isValid"
                                disabled
                                active-color="#07AAF9"
                                inactive-color="#FF5F33"
                                inline-prompt
                                :active-text="$t('tqK3NuaPwyfNtmCtUjfMc')"
                                :inactive-text="$t('q4t2O0Ze9Xzq62dJGwSJk')"
                            />
                        </el-form-item>
                    </el-col>
                    <el-col :xs="24" :sm="12" :md="12" :lg="12" :xl="12" class="mb20">
                        <el-form-item :label-width="formLabelWidth" :label="$t('xxAj6fsjvIsQrMdlNpolv')">
                            <el-input readonly v-model="ruleForm.createdTime" type="textarea" :placeholder="$t('xxAj6fsjvIsQrMdlNpolv')" clearable />
                        </el-form-item>
                    </el-col>
                    <el-col :xs="24" :sm="12" :md="12" :lg="12" :xl="12" class="mb20">
                        <el-form-item :label-width="formLabelWidth" :label="$t('v7AhfaNeGaFoPfZzgpFk')">
                            <el-input readonly v-model="ruleForm.createdUserName" type="textarea" :placeholder="$t('v7AhfaNeGaFoPfZzgpFk')" clearable />
                        </el-form-item>
                    </el-col>
                    <el-col :xs="24" :sm="12" :md="12" :lg="12" :xl="12" class="mb20">
                        <el-form-item :label-width="formLabelWidth" :label="$t('hMMqYalIdWhk0McqdxTg')">
                            <el-input v-if="ruleForm.updatedTime" readonly v-model="ruleForm.updatedTime" type="textarea" :placeholder="$t('hMMqYalIdWhk0McqdxTg')" clearable />
                            <el-input v-else readonly v-model="defaultVal" type="textarea" :placeholder="$t('hMMqYalIdWhk0McqdxTg')" clearable />
                        </el-form-item>
                    </el-col>
                    <el-col :xs="24" :sm="12" :md="12" :lg="12" :xl="12" class="mb20">
                        <el-form-item :label-width="formLabelWidth" :label="$t('yRc0RHyyMh9Cy0TKyYr')">
                            <el-input v-if="ruleForm.updatedUserName" readonly v-model="ruleForm.updatedUserName" type="textarea" :placeholder="$t('yRc0RHyyMh9Cy0TKyYr')" clearable />
                            <el-input v-else readonly v-model="defaultVal" type="textarea" :placeholder="$t('yRc0RHyyMh9Cy0TKyYr')" clearable />
                        </el-form-item>
                    </el-col>
                    <el-col :xs="24" :sm="12" :md="12" :lg="12" :xl="12" class="mb20">
                        <el-form-item :label-width="formLabelWidth" :label="$t('9RLaVEiJf1Z1Qv15o6Kll')">
                            <el-input v-if="ruleForm.v_Remake" readonly v-model="ruleForm.v_Remake" type="textarea" :placeholder="$t('9RLaVEiJf1Z1Qv15o6Kll')" clearable />
                            <el-input v-else readonly v-model="defaultVal" type="textarea" :placeholder="$t('9RLaVEiJf1Z1Qv15o6Kll')" clearable />
                        </el-form-item>
                    </el-col>
                </el-row>
            </el-form>

            <el-divider content-position="left"> {{ $t('yAvTtpz0zMd6C5i3TqYvd') }} </el-divider>
            <el-table class="table-s" :data="rectifyListArrOne" style="width: 100%" border>
                <el-table-column min-width="270" prop="fileOriginName" :show-overflow-tooltip="true" :label="$t('5l2R6NiV8F5KyemPq8xq')"  align="center" />
                <el-table-column min-width="160" prop="createdTime" :show-overflow-tooltip="true" :label="$t('4pvjWhhdT5Nk2JMc5rQg')"  align="center" />
                <el-table-column min-width="120" prop="createdUserName" :show-overflow-tooltip="true" :label="$t('8GbxAmDauKsBrgrQQa2')"  align="center" />
                <el-table-column min-width="120" :show-overflow-tooltip="true" :label="$t('dScKg8pBv4cupCrxspq1r')"  align="center">
                    <template #default="scope">
                        <img style="width: 30px;height: 20px;" :src="pathData + scope.row.path" />
                    </template>
                </el-table-column>
                <el-table-column min-width="120" :show-overflow-tooltip="true" :label="$t('liBmO8wb58NMw5HLu9Nf')"  align="center"  fixed="right">
                    <template #default="scope">
                        <el-link target="_blank" :href="pathData + scope.row.path" type="primary">{{ $t('i8A6uFe7Z4rYBFs9LUfm') }}</el-link>
                    </template>
                </el-table-column>
            </el-table>

            <el-divider content-position="left"> {{ $t('h1NiJFxdxXsO9UmJbeMf') }} </el-divider>
            <el-table class="table-s" :data="rectifyListArrTwo" style="width: 100%" border>
                <el-table-column min-width="270" prop="fileOriginName" :show-overflow-tooltip="true" :label="$t('5l2R6NiV8F5KyemPq8xq')"  align="center" />
                <el-table-column min-width="160" prop="createdTime" :show-overflow-tooltip="true" :label="$t('4pvjWhhdT5Nk2JMc5rQg')"  align="center" />
                <el-table-column min-width="120" prop="createdUserName" :show-overflow-tooltip="true" :label="$t('8GbxAmDauKsBrgrQQa2')"  align="center" />
                <el-table-column min-width="120" :show-overflow-tooltip="true" :label="$t('dScKg8pBv4cupCrxspq1r')"  align="center">
                    <template #default="scope">
                        <img style="width: 30px;height: 20px;" :src="pathData + scope.row.path" />
                    </template>
                </el-table-column>
                <el-table-column min-width="120" :show-overflow-tooltip="true" :label="$t('liBmO8wb58NMw5HLu9Nf')"  align="center"  fixed="right">
                    <template #default="scope">
                        <el-link target="_blank" :href="pathData + scope.row.path" type="primary">{{ $t('i8A6uFe7Z4rYBFs9LUfm') }}</el-link>
                    </template>
                </el-table-column>
            </el-table>

            <el-divider content-position="left">{{ $t('odQpuOypYmCIbyEj44TpZ') }}</el-divider>
            <el-table class="heightcss" :data="ruleForm.hazardDetail" style="width: 100%" border>
                <el-table-column min-width="200" prop="v_WorkType" :show-overflow-tooltip="true" :label="$t('9xM6FvTR_8nWq19wjfgx')"  align="center" />
                <el-table-column min-width="200" prop="v_WorkExplain" :show-overflow-tooltip="true" :label="$t('f0faXf3TEmiEjagrud8d')"  align="center" />
                <el-table-column min-width="200" prop="f_Risk_Assessment_L" :show-overflow-tooltip="true" :label="$t('kR6nl8il9ndraLnxdB3Mo')"  align="center" />
                <el-table-column min-width="200" prop="f_Risk_Assessment_E" :show-overflow-tooltip="true" :label="$t('dF0hvzTTgBxRtEjtHcQ7u')"  align="center" />
                <el-table-column min-width="200" prop="f_Risk_Assessment_C" :show-overflow-tooltip="true" :label="$t('4H_3Am3S96x5evGuS4uPz')"  align="center" />
                <el-table-column min-width="200" prop="f_Risk_Assessment_D" :show-overflow-tooltip="true" :label="$t('dEiB4EetFConPmp9cvAhZ')"  align="center" />
                <el-table-column min-width="200" prop="f_Risk_Assessment_D" :show-overflow-tooltip="true" :label="$t('dEiB4EetFConPmp9cvAhZ')"  align="center" />
                <el-table-column min-width="200" prop="v_Dangerous_Level" :show-overflow-tooltip="true" :label="$t('gCP5cJhRMe0BnrLqRs')"  align="center" />
                <el-table-column min-width="200" prop="v_Accient_TypeName" :show-overflow-tooltip="true" :label="$t('ebd7Jl2fPx6WeiyWryLYl')"  align="center" />
                <el-table-column min-width="200" :show-overflow-tooltip="true" :label="$t('fw78QmJeZpmsty3o1TeU')"  align="center">
                    <template #default="scoped">
                        <span v-if="scoped.row.v_Shielding">{{ scoped.row.v_Shielding }}</span>
                        <span v-else>-</span>
                    </template>
                </el-table-column>
                <el-table-column min-width="200" :show-overflow-tooltip="true" :label="$t('l4v70UyItNhFizQ4AInL6')"  align="center">
                    <template #default="scoped">
                        <span v-if="scoped.row.v_Advice_Shielding">{{ scoped.row.v_Advice_Shielding }}</span>
                        <span v-else>-</span>
                    </template>
                </el-table-column>
                <el-table-column min-width="200" prop="v_Control_Level" :show-overflow-tooltip="true" :label="$t('7Lw5y52b0yczYwCbDguvq')"  align="center" />
                <el-table-column min-width="200" prop="v_Control_Measures" :show-overflow-tooltip="true" :label="$t('xCeeB3WeM4ZkHhTh5btqG')"  align="center" />
                <el-table-column min-width="200" prop="v_OrgName" :show-overflow-tooltip="true" :label="$t('cw6bUPoDlHdwNcW40my')"  align="center" />
                <el-table-column min-width="200" :show-overflow-tooltip="true" :label="$t('y7I9J0Du746oyZTnse2kM')"  align="center">
                    <template #default="scoped">
                        <span v-if="scoped.row.v_EmpName">{{ scoped.row.v_EmpName }}</span>
                        <span v-else>-</span>
                    </template>
                </el-table-column>
                <el-table-column min-width="200" prop="v_PushTypeName" :show-overflow-tooltip="true" :label="$t('dHxlDhT9RRckG6mYRjgeQ')"  align="center" />
                <el-table-column min-width="200" :show-overflow-tooltip="true" :label="$t('s4KbtSrTfOzuWyRcHgTxx')"  align="center">
                    <template #default="scope">
                        <template v-if="scope.row.v_JobFilePath">
                            <el-link target="_blank" :href="pathData + scope.row.filePaths" type="primary">{{ $t('2KyEk7Ir2Lz3bN9ByjSaE') }}</el-link>
                        </template>
                        <template v-else>
                            <div style="color:#c0c4cc;">
                                <span>{{ $t('66gSt7xsIbieLa59Td1H') }}</span>
                            </div>
                        </template>
                    </template>
                </el-table-column>
                <el-table-column min-width="200" prop="v_Remake" :show-overflow-tooltip="true" :label="$t('9RLaVEiJf1Z1Qv15o6Kll')"  align="center" />
                <el-table-column min-width="200" prop="createdTime" :show-overflow-tooltip="true" :label="$t('xxAj6fsjvIsQrMdlNpolv')"  align="center" />
                <el-table-column min-width="200" prop="createdUserName" :show-overflow-tooltip="true" :label="$t('v7AhfaNeGaFoPfZzgpFk')"  align="center" />
                <el-table-column min-width="200" :show-overflow-tooltip="true" :label="$t('hMMqYalIdWhk0McqdxTg')"  align="center">
                    <template #default="scoped">
                        <span v-if="scoped.row.updatedTime">{{ scoped.row.updatedTime }}</span>
                        <span v-else>-</span>
                    </template>
                </el-table-column>
                <el-table-column min-width="200" :show-overflow-tooltip="true" :label="$t('2Gu4SnAncIkNclplw6vNj')"  align="center">
                    <template #default="scoped">
                        <span v-if="scoped.row.updatedUserName">{{ scoped.row.updatedUserName }}</span>
                        <span v-else>-</span>
                    </template>
                </el-table-column>
            </el-table>

            <template #footer>
                <el-button @click="cancelUseClick">{{ $t('9YxdWp3OFxHvMW4VGh71') }}</el-button>
            </template>
        </el-dialog>
    </div>
</template>
<script lang="ts">
import { defineComponent, ref, reactive , computed , toRef , toRefs , toRaw , onMounted , watch } from 'vue'
import { FormInstance, FormRules , ElMessage, ElButton, ElCol, ElDatePicker, ElDialog, ElDivider, ElForm, ElFormItem, ElInput, ElOption, ElRadio, ElRow, ElSelect, ElTable, ElTableColumn } from 'element-plus'
import getTableData from '/@/utils/getTableData'
import useCurrentInstance from '/@/utils/hook/useCurrentInstance';

/*** 定义接口基础数据类型 */
interface formType {
    ruleForm: any,
}
/*** form 表单数据类型 */
type ruleFormType = {}
export default defineComponent( {
    name: 'huizong-detail',
    components: {},
    props: {
        isUseDialog:{
            type: Boolean,
            default: false,
        },
        repairInfo: {
            type: String,
            default: ''
        }
    },
    setup(props,ctx){
        const { proxy } = useCurrentInstance();
        const $t = proxy.$t;
        
        const titleCon = ref()
        const pathData = ref(import.meta.env.VITE_API_URL + '/') // 获取地址
        const fileListArr = ref([])
        const rectifyListArrOne = ref([])
        const rectifyListArrTwo = ref([])

        /*** state 引用接口定义基础数据初始值 */
        const state = reactive < formType > ({
            ruleForm: {} as ruleFormType
        })

        /*** handleClose 关闭按钮点击事件 */
        const handleClose = () => {
            ctx.emit('cancelDetailClick')
        }

        /*** cancelUseClick 取消事件 */
        const cancelUseClick = () => {
            ctx.emit('cancelDetailClick')
        }
        /*** 监听isUseDialog的变化 */
        watch(() => props.isUseDialog,(newVal) => {
            if(newVal){
                titleCon.value = $t('deaKTj9gswMt8GaC9Sks')
                let getData = JSON.parse(props.repairInfo)
                rectifyListArrOne.value = []
                rectifyListArrTwo.value = []
                console.log(getData,'getData')
                if(getData.n_isValid === 1){ getData.n_isValid = true }
                if (getData.n_isValid === 2) { getData.n_isValid = false }
                
                if(getData.v_FilePath && getData.v_FilePath.length !== 0){
                    rectifyListArrOne.value = getData.v_FilePath
                }else{
                    rectifyListArrOne.value = [] 
                }
                if(getData.v_ChangeFilePath && getData.v_ChangeFilePath.length !== 0){
                    rectifyListArrTwo.value = getData.v_ChangeFilePath
                }else{
                    rectifyListArrTwo.value = [] 
                }
                
                if(getData.hazardDetail && getData.hazardDetail.length !== 0){
                    getData.hazardDetail.map((i:any) => {
                        if(i.n_PushType <= 1){
                            i.v_PushTypeName = $t('7dvrp8KNteJ2KsyX53N')
                        }else if(i.n_PushType === 2){
                            i.v_PushTypeName = $t('0GdEpZhBB3RGlirtCm1U')
                        }else if(i.n_PushType === 3){
                            i.v_PushTypeName = $t('w3sd0wQwiYthGeopJcU4t')
                        }else if(i.n_PushType === 4){
                            i.v_PushTypeName = $t('eec8W28NIj_1hBweAkWs')
                        }else{
                            i.v_PushTypeName = $t('tuRoDlk7koL463Gf9SbzY')
                        }
                    })
                }else{
                    getData.hazardDetail = []
                }
                state.ruleForm = getData
            }
        })

        /*** isUseDialog 响应弹窗的关闭  */
        const isUseDialog = computed(() => {
            return props.isUseDialog
        })

        return {
            handleClose,
            cancelUseClick,
            titleCon,
            ...toRefs(state),
            isUseDialog,
            pathData,
            formLabelWidth: '100px',
            fileListArr,
            rectifyListArrOne,
            rectifyListArrTwo,
            defaultVal: '-',
        }
    },
} )
</script>
<style scoped lang="scss">
    :deep(.el-link__inner){
        color: #0052D9;
    }
    // :deep(.el-divider__text){
    //     color: #303133;
    //     font-weight: bold;
    // }
    .path_look{
        display: block;
        width: 100%;
        border: 1px solid #e4e7ed;
        border-radius: 4px;
        span{
          display: block;
          margin-left: 15px;  
          color: #606266;
        }
    }
    .second-level-detail{
        width: 100%;
        margin: auto;
        padding: 10px;
        border: 1px solid #fcfafa;
        border-radius: 2px;
    }
    .data-detail{
        width: 100%;
        // border-bottom: 1px solid #dcdfe6;
        // border-radius: 2px;
        padding:0 10px;
    }
</style>